<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorator="layouts/main">
<head>
    <meta http-equiv="refresh" th:content="${@loginCookieCsrfRepository.getCookieMaxAge()}" />
</head>
<div class="island" layout:fragment="page-content">
    <h1 th:text="${T(org.cloudfoundry.identity.uaa.zone.IdentityZoneHolder).uaa ? 'Welcome!':'Welcome to '+zone_name+'!'}">Welcome!</h1>
    <div class="island-content">

        <div th:if="${error}"
             class="alert alert-error">
            <p th:text="${#messages.msgOrNull('login.' + error) ?: 'Error!'}"></p>
        </div>

        <div th:unless="${error}"
             th:if="${param.error}"
             class="alert alert-error">
            <p th:text="${#messages.msgOrNull('login.' + param.error[0]) ?: 'Error!'}"></p>
        </div>

        <div th:if="${param.success}" class="alert alert-success">
            <p th:text="${#messages.msgOrNull('login.' + param.success[0]) ?: 'Success!'}"></p>
        </div>

        <th:block th:if="${fieldUsernameShow}">
        <form th:action="@{/login.do}" method="post" novalidate="novalidate" accept-charset="UTF-8">
            <input th:each="prompt,iter : ${prompts}"
                   th:name="${prompt.key}"
                   th:type="${prompt.value[0]}"
                   th:placeholder="${prompt.value[1]}"
                   th:attr="autocomplete=${(prompt.value[0] == 'password') ? 'off' : null}"
                   class="form-control"/>
            <input type="submit" value="Sign in" class="island-button"/>
            <input th:if="${session.SPRING_SECURITY_SAVED_REQUEST}"
                   th:unless="${form_redirect_uri}"
                   th:name="form_redirect_uri"
                   th:type="hidden"
                   th:value="${session.SPRING_SECURITY_SAVED_REQUEST.redirectUrl}"/>
            <input th:if="${form_redirect_uri}"
                   th:name="form_redirect_uri"
                   th:type="hidden"
                   th:value="${form_redirect_uri}"/>
            <input th:if="${param.login_hint}"
                   th:unless="${login_hint}"
                   th:name="login_hint"
                   th:type="hidden"
                   th:value="${param.login_hint}"/>
            <input th:if="${login_hint}"
                   th:name="login_hint"
                   th:type="hidden"
                   th:value="${login_hint}"/>
        </form>
        </th:block>
        <div class="saml-login">
            <p th:if="${showLoginLinks==true and fieldUsernameShow}">or sign in with: </p>
            <div th:each="idp : ${idpDefinitions}" th:if="${idp.showSamlLink}">
                <a href="" th:href="@{saml/discovery(returnIDParam=idp,entityID=${entityID},idp=${idp.idpEntityAlias},isPassive=true)}" th:text="${idp.linkText}" class="saml-login-link">Use your corporate credentials</a>
            </div>
            <div th:each="oauthLink : ${oauthLinks}" >
                <div>
                    <a href="" th:href="${oauthLink.key}" th:text="${oauthLink.value}" class="saml-login-link">Use your corporate credentials</a>
                </div>
            </div>
        </div>
        <th:block th:if="${linkCreateAccountShow}">
        <span class="left">
            <a th:unless="${#strings.isEmpty(links['createAccountLink'])}" href="/create_account" th:href="@{${links['createAccountLink']}}" class="link-lowlight">Create account</a>
        </span><span class="right" th:unless="${#strings.isEmpty(links['forgotPasswordLink'])}">
            <a href="/forgot_password" th:href="@{${links['forgotPasswordLink']}}" class="link-lowlight">Reset password</a>
        </span>
        </th:block>
    </div>
</div>
</html>
